import TYPE from "../type";

import {getBannerList,getRecommend,getActivity,getProductlist} from "../../api/index"


export function getBanner(){
    return dispatch=>{
            getBannerList().then(res=>{
            	dispatch({
            		type:TYPE.GET_BANNER,
            		data:res.data.data
            	})
            })
    }
}


export function getRecommendList(){
    return dispatch=>{
            getRecommend().then(res=>{
            	dispatch({
            		type:TYPE.GET_RECOMMEND,
            		data:res.data.data
            	})
            })
    }
}

export function getActivityList(){
    return dispatch=>{
            getActivity().then(res=>{
                dispatch({
                    type:TYPE.GET_ACTIVITY,
                    data:res.data.data
                })
            })
    }
}

export function getProduct(params){
    return dispatch=>{
            getProductlist(params).then(res=>{
        
                if(res.data.code===0){
                    dispatch({
                        type:TYPE.GET_PRODUCTLIST,
                        data:res.data.data
                    })
                }else{
                    dispatch({
                        type:TYPE.SET_ISFINISH
                    })
                }
                
            })
    }
}


